#include "duplicate.h"
-#include <algorithm> // for stable_sort
-
-#include <QDateTime> // for QDateTime
#include <QList> // for QList, QList<>::iterator, QList<>::const_iterator
#include <QMultiHash> // for QMultiHash
+#include <QtCore> // for qAsConst
#include "defs.h"
-#include "geocache.h" // for Geocache
-#include "src/core/datetime.h" // for DateTime
#if FILTERS_ENABLED
#define MYNAME "duplicate"
-/*
-
-It looks odd that we have different comparisons for date and index.
- If exported if a < b return 1
- if index if a < b return -1
-
-The reason is that we want to sort in reverse order by date, but forward
-order by index. So if we have four records:
-
- date index
- June 24 0
- June 25 1
- June 25 2
- June 24 3
-
-we want to sort them like this:
-
- date index
- June 25 1
- June 25 2
- June 24 0
- June 24 3
-
-Thus, the first point we come across is the latest point, but if we
-have two points with the same export date/time, we will first see the
-one with the smaller index (i.e. the first of those two points that we
-came across while importing waypoints.)
-
-In the (common) case that we have no exported dates, the dates will all
-be zero so the sort will end up being an expensive no-op. However, the
-complexity of this filter is dominated by other concerns.
-*/
void DuplicateFilter::init()
{
void DuplicateFilter::process()
{
- auto wptlist = *global_waypoint_list;
-
- auto compare_lambda = [](const Waypoint* wa, const Waypoint* wb)->bool {
- return wa->gc_data->exported > wb->gc_data->exported;
- };
- std::stable_sort(wptlist.begin(), wptlist.end(), compare_lambda);
-
QMultiHash<QString, Waypoint*> wpthash;
- for (Waypoint* waypointp : wptlist) {
+ for (Waypoint* waypointp : qAsConst(*global_waypoint_list)) {
QString key;
if (lcopt) {
status_t is_available:2;
status_t is_memberonly:2;
status_t has_customcoords:2;
- gpsbabel::DateTime exported;
gpsbabel::DateTime last_found;
QString placer; /* Placer name */
int placer_id; /* Placer id */
if (tag->child) {
fprint_xml_chain(tag->child, wpt);
}
- if (wpt && wpt->gc_data->exported.isValid() &&
- tag->tagname.compare(u"groundspeak:cache") == 0) {
- writer->writeTextElement(QStringLiteral("time"),
- wpt->gc_data->exported.toPrettyString());
- }
writer->writeEndElement();
}
if (!tag->parentcdata.isEmpty()) {
+++ /dev/null
-No,Latitude,Longitude,Name,Exported
-1,40.0,-105.1,"zero",2015/06/24 00:00:00
-1,40.0,-105.2,"one",2015/06/25 00:00:01
-1,40.0,-105.2,"two",2015/06/25 00:00:00
-1,40.0,-105.1,"three",2015/06/24 00:00:01
+++ /dev/null
-No,Latitude,Longitude,Name,Exported\r
-1,40.000000,-105.200000,"one","2015/06/25 00:00:01"\r
-2,40.000000,-105.100000,"three","2015/06/24 00:00:01"\r
+++ /dev/null
-No,Latitude,Longitude,Name,Exported
-1,40.0,-105.1,"zero",2015/06/24 00:00:02
-1,40.0,-105.2,"one",2015/06/25 00:00:01
-1,40.0,-105.2,"two",2015/06/25 00:00:02
-1,40.0,-105.1,"three",2015/06/24 00:00:01
+++ /dev/null
-No,Latitude,Longitude,Name,Exported\r
-1,40.000000,-105.100000,"zero","2015/06/24 00:00:02"\r
-2,40.000000,-105.200000,"two","2015/06/25 00:00:02"\r
gpsbabel -i geo -f ${REFERENCE}/geocaching.loc -f ${REFERENCE}/geocaching.loc -x duplicate,shortname \
-o csv -F ${TMPDIR}/filterdupe.csv2
sort_and_compare ${TMPDIR}/filterdupe.csv1 ${TMPDIR}/filterdupe.csv2
-
-gpsbabel -i unicsv,utc -f ${REFERENCE}/duplicate_exported_1.csv -x duplicate,location -o unicsv,utc -F ${TMPDIR}/duplicate_exported_1~csv.csv
-compare ${REFERENCE}/duplicate_exported_1~csv.csv ${TMPDIR}/duplicate_exported_1~csv.csv
-gpsbabel -i unicsv,utc -f ${REFERENCE}/duplicate_exported_2.csv -x duplicate,location -o unicsv,utc -F ${TMPDIR}/duplicate_exported_2~csv.csv
-compare ${REFERENCE}/duplicate_exported_2~csv.csv ${TMPDIR}/duplicate_exported_2~csv.csv
{ "diff", fld_gc_diff, kStrAny },
{ "arch", fld_gc_is_archived, kStrAny },
{ "avail", fld_gc_is_available, kStrAny },
- { "exported", fld_gc_exported, kStrAny },
{ "found", fld_gc_last_found, kStrAny },
{ "placer_id", fld_gc_placer_id, kStrAny },
{ "placer", fld_gc_placer, kStrAny },
case fld_gc_diff:
case fld_gc_is_archived:
case fld_gc_is_available:
- case fld_gc_exported:
case fld_gc_last_found:
case fld_gc_placer:
case fld_gc_placer_id:
case fld_gc_is_available:
gc_data->is_available = unicsv_parse_status(value);
break;
- case fld_gc_exported: {
- QTime etime;
- QDate edate;
- etime = unicsv_parse_time(value, edate);
- if (edate.isValid() || etime.isValid()) {
- gc_data->exported = unicsv_adjust_time(edate, etime, true);
- }
- }
break;
case fld_gc_last_found: {
QTime ftime;
if (gc_data->is_available != Geocache::status_t::gs_unknown) {
unicsv_outp_flags[fld_gc_is_available] = true;
}
- if (gc_data->exported.isValid()) {
- unicsv_outp_flags[fld_gc_exported] = true;
- }
if (gc_data->last_found.isValid()) {
unicsv_outp_flags[fld_gc_last_found] = true;
}
*fout << unicsv_fieldsep;
}
}
- if (unicsv_outp_flags[fld_gc_exported]) {
- if (gc_data) {
- unicsv_print_date_time(gc_data->exported);
- } else {
- *fout << unicsv_fieldsep;
- }
- }
if (unicsv_outp_flags[fld_gc_last_found]) {
if (gc_data) {
unicsv_print_date_time(gc_data->last_found);
if (unicsv_outp_flags[fld_gc_is_available]) {
*fout << unicsv_fieldsep << "Available";
}
- if (unicsv_outp_flags[fld_gc_exported]) {
- *fout << unicsv_fieldsep << "Exported";
- }
if (unicsv_outp_flags[fld_gc_last_found]) {
*fout << unicsv_fieldsep << "Last Found";
}
fld_gc_diff,
fld_gc_is_archived,
fld_gc_is_available,
- fld_gc_exported,
fld_gc_last_found,
fld_gc_placer,
fld_gc_placer_id,
diff = <link linkend="style_def_geodiff">Geocache difficulty</link>
ele = Elevation (in meters). For feet use "ele ft", "eleft", "ele feet", or "elefeet".
e/w = 'e' for eastern hemisphere, 'w' for western
- exported = Geocache export date
found = <link linkend="style_def_geofound">Geocache last found date</link>
fix = 3d, 2d, etc.
gcid = Geocache cache id. This accepts GC-ID ("575006") and GC-Code ("GC1234G").